﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Yipusoft.TownshipEnterprise.Model;
using Yipusoft.TownshipEnterprise.BLL;
using System.Collections.Generic;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using Yipusoft.Account.Model;

public partial class TownshipEnterprise_TownBasicEdit : System.Web.UI.Page
{

   public static Guid townbasicID = Guid.Empty;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TabContainer1.ActiveTabIndex = 0;
            //TabContainer1.Tabs[1].Visible = false;
           
            BindDDLPhoto();

            
            try
            {
                townbasicID =new Guid( Request.Params["id"]);

            }
            catch (Exception)
            {
                Response.Write("<script language=javascript>alert('获取信息错误，请返回重试！')</script>");
                return;
            }
            if (townbasicID != null)
            {
                //读取单位信息，赋值页面
                TownBasicInfo info = new TownBasicInfo();
                info = TownBasic.GetTownBasic(townbasicID);

                rblFBType.SelectedValue = info.FBType;
                DptSmall.SelectedValue = info.DepartmentID;
                txtArmy.Text = info.Army;
                txtAddress.Text = info.Address;
                txtRange.Text = info.Range;
                txtUnitLeadName.Text = info.UnitLeadName;
                txtUnitLeadTel.Text = info.UnitLeadTel;
                txtArmyLeadName.Text = info.ArmyLeadName;
                txtArmyLeadTel.Text = info.ArmyLeadTel;
                txtLongitude.Text = info.longitude.ToString();
                txtLatitude.Text = info.latitude.ToString();
                txtMemberCount.Text = info.MemberCount.ToString();
                //txtMemberName.Text = info.MemberName;
                //txtArea.Text = info.Area.ToString();
                //rblArea.SelectedIndex = info.AreaIs ? 0 : 1;
                txtRealArea.Text = info.RealArea.ToString();
                txtBuildArea.Text = info.BuildArea.ToString();

                GridBind("");
                DptBig.SelectedValue = info.DepartmentID.Substring(0,4)+"000";
                DepartmentListBind();
                DptSmall.SelectedValue = info.DepartmentID;
            }
            BindDateList(townbasicID.ToString());
        }
    }

    /// <summary>
    /// 绑定支队
    /// </summary>
    /// <param name="departmentID"></param>
    private void GridBind(string departmentID)
    {
        //btnSave.Visible = IsTrue();
        //btnUpLoad.Visible = IsTrue();

        // Bind(0);
        //显示支队
        ////this.DptBig.DataSource = Yipusoft.Account.BLL.Department.GetList(" Right(DepartmentID,2)='00'");
        ////this.DptBig.DataTextField = "AliasName";
        ////this.DptBig.DataValueField = "DepartmentID";
        ////this.DptBig.DataBind();


        this.DptBig.DataSource = Yipusoft.Account.BLL.Department.GetList(" Right(DepartmentID,2)='00'");



        UserInfo userInfo = Yipusoft.Account.BLL.User.GetUser(User.Identity.Name);
        DepartmentInfo department = Yipusoft.Account.BLL.Department.GetDepartment(userInfo.DepartmentID);
        if (userInfo.DepartmentID.Substring(0, 4) == "1300")
        {
            DptBig.DataSource = Yipusoft.Account.BLL.Department.GetList(" (SUBSTRING(DepartmentID, 5, 3) = '000') and DepartmentID<>'1300000' ");

        }
        else
        {
            DptBig.DataSource = Yipusoft.Account.BLL.Department.GetList(" DepartmentID= '" + department.DepartmentID.Substring(0, 4) + "000' ");

        }

        this.DptBig.DataTextField = "AliasName";
        this.DptBig.DataValueField = "DepartmentID";
        this.DptBig.DataBind();


        //Yipusoft.Account.Model.DepartmentInfo info = Yipusoft.Account.BLL.Department.GetDepartment(Request["DepartmentID"]);
        ////if (info != null)
        ////{
        ////    this.ddlPhotoName.Items.Insert(0, new ListItem(info.FullName, info.FullName));
        ////}

        //this.DptFireType.DataSource = Yipusoft.Common.BLL.CodeItem.GetList2(" GroupID='XFZLB'");
        //this.DptFireType.DataTextField = "ItemName";
        //this.DptFireType.DataValueField = "ItemID";
        //this.DptFireType.DataBind();

        //this.DptLevel.DataSource = Yipusoft.Common.BLL.CodeItem.GetList2(" GroupID='XFZDJ'");
        //this.DptLevel.DataTextField = "ItemName";
        //this.DptLevel.DataValueField = "ItemID";
        //this.DptLevel.DataBind();

       
        //DptBig.Items.Insert(0, new ListItem("请选择单位", "00"));
        //List<DepartmentPhotoInfo> departmentPhotos = DepartmentPhoto.GetPhotoListByDepartmentID(departmentID);
        //gvDepartmentPhoto.DataSource = DepartmentPhoto.GetPhotoListByDepartmentID(departmentID);
        //gvDepartmentPhoto.DataBind();
        if (Request["DepartmentID"] != null)
        {
            if ((!Request["DepartmentID"].Substring(0, 4).Equals("13121")) && (!Request["DepartmentID"].Substring(0, 4).Equals("13131")))
            {
                this.DptBig.SelectedValue = Request["DepartmentID"].Substring(0, 4) + "000";
            }
            else
            {
                this.DptBig.SelectedValue = Request["DepartmentID"].Substring(0, 5) + "00";
            }
            this.DptBig_SelectedIndexChanged(this.DptBig, new EventArgs());
            this.DptSmall.SelectedValue = Request["DepartmentID"];
            this.txtArmy.Text = DptSmall.SelectedItem.Text;
        }


    }

    /// <summary>
    /// 绑定县
    /// </summary>
    void DepartmentListBind()
    {
        DptSmall.Items.Clear();
        string strWhere = "DepartmentID like '" + DptBig.SelectedValue.Substring(0, 4) + "2%' and   SUBSTRING(DepartmentID, 5, 1)<>'0' ";
        List<DepartmentInfo> list = Yipusoft.Account.BLL.Department.GetList(strWhere);
        foreach (DepartmentInfo dpt in list)
        {
            dpt.ShortName = dpt.ShortName.Replace("消防科", "");
            dpt.ShortName = dpt.ShortName.Replace("大队", "");
            dpt.ShortName = dpt.ShortName.Replace("消防", "");
        }
        DptSmall.DataSource = list;
        DptSmall.DataBind();
        // BingDDLBasicInfo();
    }

    //根据支队列出大队
    protected void DptBig_SelectedIndexChanged(object sender, EventArgs e)
    {
        //if (DptBig.Items.Count <= 0)
        //    return;
        //if (DptBig.SelectedValue.ToString() == "00")
        //    return;
        //this.DptSmall.DataSource = Yipusoft.Account.BLL.Department.GetList("Left(DepartmentID,4)='" + DptBig.SelectedValue.Substring(0, 4) + "'");
        //this.DptSmall.DataTextField = "ShortName";
        //this.DptSmall.DataValueField = "DepartmentID";
        //this.DptSmall.DataBind();
        //this.txtArmy.Text = DptSmall.SelectedItem.Text;

        if (DptBig.Items.Count <= 0)
            return;
        if (DptBig.SelectedValue.ToString() == "00")
            return;
        this.DptSmall.DataSource = Yipusoft.Account.BLL.Department.GetList("Left(DepartmentID,5)='" + DptBig.SelectedValue.Substring(0, 4) + "2'");
        DepartmentListBind();
        this.txtArmy.Text = DptSmall.SelectedItem.Text;
    }

    /// <summary>
    /// 绑定显示库室图片类型
    /// </summary>
    private void BindDDLPhoto()
    {
        string strWhere = "ParentsID = '6'";
        List<TownPicsTypeInfo> tpy = TownPicsType.GetList(strWhere);
        if (tpy.Count > 0)
        {
            ddlPhotoName.Items.Clear();
            ddlPhotoName.DataSource = tpy;
            ddlPhotoName.DataTextField = "PicType";
            ddlPhotoName.DataValueField = "id";
            ddlPhotoName.DataBind();
        }
    }

    //保存基本信息
    protected void btnSave_Click(object sender, EventArgs e)
    {

        if (saveInfo(  townbasicID))
            Session["TownBasicID"] = townbasicID;
    }
    /// <summary>
    /// 添加基本信息
    /// </summary>
    /// <returns></returns>
    private bool saveInfo(Guid id)
    {
        TownBasicInfo info = new TownBasicInfo();
        try
        {
            info.FBType = rblFBType.SelectedValue.ToString();
            info.DepartmentID = DptSmall.SelectedValue;
            info.Army = txtArmy.Text;
            info.Address = txtAddress.Text;
            info.Range = txtRange.Text;
            info.UnitLeadName = txtUnitLeadName.Text;
            info.UnitLeadTel = txtUnitLeadTel.Text;
            info.ArmyLeadName = txtArmyLeadName.Text;
            info.ArmyLeadTel = txtArmyLeadTel.Text;
            info.longitude = Convert.ToDouble(txtLongitude.Text);
            info.latitude = Convert.ToDouble(txtLatitude.Text);
            info.MemberCount = Convert.ToInt32(txtMemberCount.Text);
            //info.MemberName = txtMemberName.Text;
            //info.AreaIs = rblArea.SelectedIndex == 0 ? true : false;
            //info.Area = Convert.ToDouble(txtArea.Text);
            info.BuildArea = Convert.ToDouble(txtBuildArea.Text);
            info.RealArea = Convert.ToDouble(txtRealArea.Text);
        }
        catch (Exception)
        {
            Response.Write("<script language=javascript>alert('填写错误！')</script>");
        }



        info.Id = id;
      

        //添加照片--数据库
        TownPicsInfo pic = new TownPicsInfo();
        pic.id = Guid.NewGuid();
        pic.TownBasicInfoID = info.Id;


        //上传图片文件
        bool img = false;
        if (fuDepartmentPhoto2.FileName.Length > 0)
        {
            string path = string.Empty;
            HttpFileCollection files = HttpContext.Current.Request.Files;
            if (files.Count > 0)
            {

                for (int i = 0; i < files.Count; i++)
                {
                    HttpPostedFile file = files[i];
                    if (file.ContentLength == 0)
                    {

                        break;
                    }
                    else
                    {
                        string picName = DateTime.Now.ToString("yyyyMMddHHmmssff");
                        img = SaveImg(picName, "1", file, out path);
                        if (!img)
                            return false;
                        else
                        {
                            if (file.FileName.IndexOf(fuDepartmentPhoto1.FileName) > 0)
                            {
                                //队领导姓名
                                pic.PicDescript = txtArmyLeadName.Text;
                                pic.PicPath = path;
                                pic.TownPicstypeID = "b";
                                bool b1 = TownPics.Insert(pic);
                                if (!b1)
                                {

                                    string allPath = Request.MapPath("") + "\\" + @path;
                                    try
                                    {
                                        File.Delete(allPath);
                                    }
                                    catch
                                    { }
                                    Response.Write("<script language=javascript>alert('图片上传失败！')</script>");
                                    return false;
                                }
                            }
                            else if (file.FileName.IndexOf(fuDepartmentPhoto0.FileName) > 0)
                            {
                                //单位领导
                                pic.id = Guid.NewGuid();
                                pic.PicDescript = txtUnitLeadName.Text;
                                pic.PicPath = path;
                                pic.TownPicstypeID = "a";
                                bool b2 = TownPics.Insert(pic);
                                if (!b2)
                                {
                                    string allPath = Request.MapPath("") + "\\" + @path;
                                    try
                                    {
                                        File.Delete(allPath);
                                    }
                                    catch
                                    { }
                                    Response.Write("<script language=javascript>alert('图片上传失败！')</script>");
                                    return false;
                                }
                            }
                            else if (file.FileName.IndexOf(fuDepartmentPhoto2.FileName) > 0)
                            {
                                //单位外观
                                pic.id = Guid.NewGuid();
                                pic.PicDescript = "单位外观图";
                                pic.PicPath = path;
                                pic.TownPicstypeID = "u";
                                bool b3 = TownPics.Insert(pic);
                                if (!b3)
                                {
                                    string allPath = Request.MapPath("") + "\\" + @path;
                                    try
                                    {
                                        File.Delete(allPath);
                                    }
                                    catch
                                    { }
                                    Response.Write("<script language=javascript>alert('图片上传失败！')</script>");
                                    return false;
                                }
                            }
                        }

                    }
                }
            }

            else
            {
                Response.Write("<script language=javascript>alert('图片地址有误！')</script>");
                return false;
            }
        }
        else
            img = true;
        //修改基本信息
        if (img)
        {
            try
            {
                //更新基本信息到数据库
                TownBasic.Update(info);

                ////添加照片--数据库
                //TownPicsInfo pic = new TownPicsInfo();
                //pic.id = Guid.NewGuid();
                //pic.TownBasicInfoID = info.Id;
                //pic.TownPicstypeID = "1";
                ////队领导
                //pic.PicDescript = txtArmyLeadName.Text; //队领导姓名
                //pic.PicPath = "";
                //bool b1 = TownPics.Insert(pic);
                ////单位领导
                //pic.id = Guid.NewGuid();
                //pic.PicDescript = txtUnitLeadName.Text;
                //pic.PicPath = "";
                //bool b2 = TownPics.Insert(pic);
                ////单位外观
                //pic.id = Guid.NewGuid();
                //pic.PicDescript = "单位外观图";
                //pic.PicPath = "";
                //bool b3 = TownPics.Insert(pic);

                Response.Write("<script language=javascript>alert('修改成功！')</script>");
                //btnSave.Enabled = false;
                //TabContainer1.Tabs[1].Visible = true;
                TabContainer1.ActiveTabIndex = 1;
                return true;
            }
            catch (Exception ex)
            {
                //从硬盘删除图片文件
                //string allPath = Request.MapPath("") + path;
                //try
                //{
                //    File.Delete(allPath);
                //}
                //catch
                //{ }
                Response.Write("<script language=javascript>alert('修改失败！')</script>");
                return false;
            }
        }
        else
        {
            Response.Write("<script language=javascript>alert('图片格式不正确，请上传 *.jpg 格式图片')</script>");
        }

        return false;
    }

    /// <summary>
    /// 上传图片
    /// </summary>
    /// <param name="name1"></param>
    /// <param name="localPath"></param>
    /// <returns></returns>
    private bool SaveImg(string name1, out string localPath)
    {
        HttpFileCollection files = HttpContext.Current.Request.Files;
        System.Text.StringBuilder strMsg = new System.Text.StringBuilder();

        bool fileOK = false;
        HttpPostedFile postedFile = files[0];

        string fileName, fileExtension;
        fileName = System.IO.Path.GetFileName(postedFile.FileName);
        if (fileName != "")
        {
            fileExtension = System.IO.Path.GetExtension(fileName);
            String[] allowedExtensions = { ".jpg" };
            for (int i = 0; i < allowedExtensions.Length; i++)
            {
                if (fileExtension.ToLower() == allowedExtensions[i])
                {
                    fileOK = true;
                    break;
                }
            }
        }
        if (fileOK)
        {

            //Bitmap bm = new Bitmap(path);
            //本地image文件夹路径
            string sPath = System.Web.HttpContext.Current.Request.MapPath("UpLoadImages/");
            //文件扩展名
            fileExtension = System.IO.Path.GetExtension(fileName).ToLower();
            //随机文件名
            Random rnd = new Random();
            // string newName = DateTime.Now.ToString().Replace("-", "").Replace(":", "").Replace(" ", "") + rnd.Next(1000).ToString();
            string newName = DateTime.Now.ToString("yyyyMMddHHmmssff");
            localPath = "UpLoadImages/" + newName + fileExtension;
            // postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("UpLoadImages/") + newName + fileExtension);

            // Bitmap bmp = new Bitmap(postedFile.InputStream);



            double width = 1024;
            double height = 768;
            //从文件取得图片对象
            System.Drawing.Image image = System.Drawing.Image.FromStream(postedFile.InputStream);
            System.Double NewWidth, NewHeight;

            if (image.Width > image.Height)
            {
                NewWidth = width;
                NewHeight = image.Height * (NewWidth / image.Width);
            }
            else
            {
                NewHeight = height;
                NewWidth = (NewHeight / image.Height) * image.Width;
            }

            if (NewWidth > width)
            {
                NewWidth = width;
            }
            if (NewHeight > height)
            {
                NewHeight = height;
            }

            //取得图片大小
            System.Drawing.Size size = new Size((int)NewWidth, (int)NewHeight);
            //新建一个bmp图片
            System.Drawing.Image bitmap = new System.Drawing.Bitmap(size.Width, size.Height);
            //新建一个画板
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);
            //设置高质量插值法
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
            //设置高质量,低速度呈现平滑程度
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            //清空一下画布
            g.Clear(System.Drawing.Color.White);
            //在指定位置画图
            g.DrawImage(image, new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height),
            new System.Drawing.Rectangle(0, 0, image.Width, image.Height),
            System.Drawing.GraphicsUnit.Pixel);

            //保存高清晰度的缩略图
            bitmap.Save(System.Web.HttpContext.Current.Request.MapPath("UpLoadImages/") + newName + fileExtension, ImageFormat.Jpeg);

            // bmp.Save(System.Web.HttpContext.Current.Request.MapPath("UpLoadImages/") + newName + fileExtension, ImageFormat.Jpeg);


            return true;

        }
        else
        {
            //提示
            localPath = "";
            return false;
        }

    }

    /// <summary>
    /// 上传图片
    /// </summary>
    /// <param name="name1">图片名称，不包含扩展名</param>
    /// <param name="typepath">图片分类目录TownItems表id</param>
    /// <param name="localPath">返回站点相对路径和文件名</param>
    /// <param name="postedFile">单独文件上传流</param>
    /// <returns></returns>
    private bool SaveImg(string name1, string typepath, HttpPostedFile postedFile, out string localPath)
    {
        //HttpFileCollection files = HttpContext.Current.Request.Files;
        System.Text.StringBuilder strMsg = new System.Text.StringBuilder();

        bool fileOk = false;



        //HttpPostedFile postedFile = files[0];

        string fileName, fileExtension;
        fileName = System.IO.Path.GetFileName(postedFile.FileName);
        if (fileName != "")
        {
            fileExtension = System.IO.Path.GetExtension(fileName);
            String[] allowedExtensions = { ".jpg" };
            for (int i = 0; i < allowedExtensions.Length; i++)
            {
                if (fileExtension.ToLower() == allowedExtensions[i])
                {
                    fileOk = true;
                    break;
                }
            }
        }
        if (fileOk)
        {

            //Bitmap bm = new Bitmap(path);
            //本地image文件夹路径
            string sPath = System.Web.HttpContext.Current.Request.MapPath("UpLoadImages\\" + typepath + "\\");
            //文件扩展名
            fileExtension = System.IO.Path.GetExtension(fileName).ToLower();
            //随机文件名
            Random rnd = new Random();
            // string newName = DateTime.Now.ToString().Replace("-", "").Replace(":", "").Replace(" ", "") + rnd.Next(1000).ToString();
            string newName = name1;
            localPath = "UpLoadImages\\" + typepath + "\\" + newName + fileExtension;
            // postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("UpLoadImages/") + newName + fileExtension);

            // Bitmap bmp = new Bitmap(postedFile.InputStream);



            double width = 1024;
            double height = 768;
            //从文件取得图片对象
            System.Drawing.Image image = System.Drawing.Image.FromStream(postedFile.InputStream);
            System.Double NewWidth, NewHeight;

            if (image.Width > image.Height)
            {
                NewWidth = width;
                NewHeight = image.Height * (NewWidth / image.Width);
            }
            else
            {
                NewHeight = height;
                NewWidth = (NewHeight / image.Height) * image.Width;
            }

            if (NewWidth > width)
            {
                NewWidth = width;
            }
            if (NewHeight > height)
            {
                NewHeight = height;
            }

            //取得图片大小
            System.Drawing.Size size = new Size((int)NewWidth, (int)NewHeight);
            //新建一个bmp图片
            System.Drawing.Image bitmap = new System.Drawing.Bitmap(size.Width, size.Height);
            //新建一个画板
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);
            //设置高质量插值法
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
            //设置高质量,低速度呈现平滑程度
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            //清空一下画布
            g.Clear(System.Drawing.Color.White);
            //在指定位置画图
            g.DrawImage(image, new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height),
            new System.Drawing.Rectangle(0, 0, image.Width, image.Height),
            System.Drawing.GraphicsUnit.Pixel);

            //保存高清晰度的缩略图
            bitmap.Save(System.Web.HttpContext.Current.Request.MapPath("UpLoadImages\\" + typepath + "\\") + newName + fileExtension, ImageFormat.Jpeg);

            // bmp.Save(System.Web.HttpContext.Current.Request.MapPath("UpLoadImages/") + newName + fileExtension, ImageFormat.Jpeg);


            return true;

        }
        else
        {
            //提示
            localPath = "";
            return false;
        }

    }
    protected void btnEdit_Command(object sender, CommandEventArgs e)
    {

    }
    protected void btnDelete_Command(object sender, CommandEventArgs e)
    {
        if (e.CommandArgument == null)
            return;
        Guid id = new Guid(e.CommandArgument.ToString());

        string path = TownPics.GetTownPics(id).PicPath;
        if (TownPics.Delete(id))
        {
            //删除文件
            string allPath = Request.MapPath("") + "\\" + @path;
            try
            {
                File.Delete(allPath);
            }
            catch (Exception ex) { }

            Response.Write("<script language=javascript>alert('删除成功。')</script>");
            //重新显示图片
            if (townbasicID == null)
            {
                BindDateList(Session["TownBasicID"].ToString());
            }
            else
            {
                BindDateList(townbasicID.ToString());
            }
        }
        else
        {
            Response.Write("<script language=javascript>alert('删除失败。')</script>");
        }
    }
    //上传图片
    protected void btnUpLoad_Click(object sender, EventArgs e)
    {
        Guid tbid = Guid.Empty;
        if (townbasicID == null)
        {
            try
            {
                tbid = (Guid)Session["TownBasicID"];

            }
            catch (Exception)
            {
                Response.Write("<script language=javascript>alert('请先保存单位信息！')</script>");
                return;
            }
        }
        else
            tbid = townbasicID;

        //保存图片
        HttpFileCollection files = HttpContext.Current.Request.Files;
        //string ssf = files.Get("ctl00$ContentPlaceHolder1$TabContainer1$TabPanel2$fuPhoto").FileName;   //

        HttpPostedFile file = files.Get("ctl00$ContentPlaceHolder1$TabContainer1$TabPanel2$fuPhoto");
        string path = string.Empty;
        string picName = DateTime.Now.ToString("yyyyMMddHHmmssff");
        bool img = SaveImg(picName, "6", file, out path);

        if (img)
        {

            //保存到数据库

            try
            {
                TownPicsInfo pic = new TownPicsInfo();
                pic.id = Guid.NewGuid();
                pic.TownBasicInfoID = tbid;
                pic.TownPicstypeID = ddlPhotoName.SelectedValue;
                pic.TownItemsID = "6";
                pic.PicPath = path;
                pic.PicDescript = txtPhotoDetails.Text;

                bool b = TownPics.Insert(pic);

                if (b)
                {
                    Response.Write("<script language=javascript>alert('保存成功！')</script>");
                    BindDateList(tbid.ToString());
                    return;
                }
                else
                {
                    //从硬盘删除图片文件
                    string allPath = Request.MapPath("") + path;
                    try
                    {
                        File.Delete(allPath);

                    }
                    catch
                    { }
                }
            }
            catch
            {
                string allPath = Request.MapPath("") + path;
                try
                {
                    File.Delete(allPath);
                }
                catch
                { }
            }
            Response.Write("<script language=javascript>alert('保存失败，请重新上传！')</script>");
        }
        else
        {
            Response.Write("<script language=javascript>alert('图片格式不正确，请上传 *.bmp,*.jpg,*.jpeg 格式图片')</script>");
        }

    }
    //翻页
    public void ListPageContral1_PageSizeChange(int pageSize, int PageIndex)
    {
        //   Bind(PageIndex);
    }
    /// <summary>
    /// 显示库室图片
    /// </summary>
    /// <param name="PerformanceID">单位id</param>
    void BindDateList(string PerformanceID)
    {
        string strWhere = "TownBasicInfoID='" + PerformanceID + "' and TownItemsID='6'";
        List<TownPicsInfo> listPics = TownPics.GetList("TownBasicInfoID", "desc", strWhere, 20, 0);

        foreach (TownPicsInfo pic in listPics)
        {
            pic.TownPicstypeID = TownPicsType.GetTownPicsType(pic.TownPicstypeID).PicType;
        }


        DltList.DataSource = listPics;
        DltList.DataBind();
    }
}
